<div class="row-fluid sortable">		
    <div class="box span12">
        <div class="box-header" data-original-title>
            <h2><i class="icon-user"></i><span class="break"></span>Lĩnh vực -  Danh mục</h2>
            <div class="box-icon">
                <a href="#" class="btn-setting"><i class="fa-icon-wrench"></i></a>
                <a href="#" class="btn-minimize"><i class="fa-icon-chevron-up"></i></a>
                <a href="#" class="btn-close"><i class="fa-icon-remove"></i></a>
            </div>
        </div>
        <div class="box-content"> 
            <div class="row-fluid LinhVuc-DanhMuc">
                <div class="span6">
                    <table id="tbLinhVuc" class="table table-bordered bootstrap-datatable datatable">
                        <thead>
                            <tr>
                                <th>Id</th>
                                <th>Tên Lĩnh vực</th>
                                <th>Actions</th>
                            </tr>
                        </thead>   
                        <tbody>
                            <?php foreach ($LinhVucs as $LinhVuc) { ?>
                                <tr class="linh-vuc-row" data-id="<?php echo $LinhVuc->Id; ?>" style="cursor: pointer;">
                                    <td><?php echo $LinhVuc->Id; ?></td>
                                    <td><a class="editable" href="#" data-name="TenLinhVuc" data-type="text" data-pk="<?php echo $LinhVuc->Id; ?>" data-url="<?php echo Yii::app()->createUrl('admin/default/EditLinhVuc'); ?>"> <?php echo $LinhVuc->Ten; ?></a></td>
                                    <td class="center">
                                        <a class="btn btn-danger btn-delete-lv" href="#" title="Xóa Danh mục này">
                                            <i class="fa-icon-trash icon-white"></i> 
                                        </a>
                                    </td>
                                </tr>
                            <?php } ?>
                        </tbody>
                    </table>   
                </div>
                <div class="span6"  id="Danh-Muc-Biz">

                </div>
            </div>
        </div>
    </div><!--/span-->

</div><!--/row-->

<script>
    $(document).ready(function() {
        //turn to inline mode
        $.fn.editable.defaults.mode = 'inline';
        $('.editable').editable({
            onblur: 'submit',
            success: function(data, config) {
                if (data !== 'success') {
                    return data;
                }
            }
        });
        $('.linh-vuc-row').click(function() {
            var id = $(this).attr('data-id');
            URL = '<?php echo Yii::app()->createUrl('admin/default/GetDanhMuc'); ?>';
            $.post(URL, {Id: id}, function(data) {
                $('#Danh-Muc-Biz').html(data);
            });
        });
        $('.btn-delete-lv').click(function(){
            if (!confirm('Bạn thật sự muốn xóa Lĩnh vực này?')) {
                return;
            }
            var object = $(this).parent().parent();
            var Id = object.attr('data-id');
            URL = '<?php echo Yii::app()->createUrl('admin/default/DeleteLinhVuc'); ?>';
            $.post(URL, {Id: Id}, function(data) {
                if (data === 'success') {
                    object.remove();
                } else {
                    alert(data);
                }
            });
        });
    });
</script>